"""
离线上料控制器
"""
class OfflineZmc:
    def __init__(self):
        self.handler = c_longlong()
        self.ip = "192.168.0.10"


    def __del__(self):
        self.close_zmc()

    def re_connect_zmc(self) -> DataResult:
        self.close_zmc()
        result = zmc_base.reconnect_zmc(self.handler,self.ip)
        if result.state:
            debug_produce(f"离线上料连接成功,ip: {self.ip}")
            res = self.set_offline_zmc_params_to_zmc()
            if res.state:
                debug_produce(f"离线上料参数设置成功,ip: {self.ip}")
            else:
                debug_produce(f"离线上料参数设置失败,ip: {self.ip}")
        else:
            debug_produce(f"离线上料连接失败,ip: {self.ip}")
            return result
        return result

    def close_zmc(self):
        return zmc_base.close_zmc(self.handler)

    def check_connect(self):
        return zmc_base.check_connect_zmc(self.handler)   
    
    def rs_stop(self):
        return zmc_base.rs_stop(self.handler)

   
